/*
 * @Author: your name
 * @Date: 2019-10-23 22:49:21
 * @LastEditors: your name
 * @LastEditTime: 2019-10-29 22:42:21
 * @Description: description
 * @FilePath: \nodework\vueblog\src\main.js
 */

// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'

import router from './router'
import ViewUI from 'view-design'
import 'view-design/dist/styles/iview.css'
import ElementUI from 'element-ui'
// import 'tailwindcss/tailwind.css'
import 'element-ui/lib/theme-chalk/index.css'
import './assets/_global.css' // 引入全局tailwindcss
import store from './store/store'

const version = Number(Vue.version.split('.')[0])

console.log(version)

Vue.use(ViewUI)
Vue.use(ElementUI)

console.log('vueconfig', Vue.config)
Vue.config.productionTip = false
if (process.env.NODE_ENV !== 'producion') require('./mock/mock.js')

router.beforeEach((to, from, next) => {
  if (to.meta.needLogin) {
    if (window.sessionStorage.data) {
      next()
    } else {
      next({
        path: '/login',
        query: {
          from: from.fullPath
        }
      })
    }
  } else {
    next()
  }
})
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>'
})
